#ifndef _MY_TABLE_HPP
#define _MY_TABLE_HPP

#include <list>
#include <vector>

typedef list < vector < OBJID > >::iterator LIter;


struct MyTable
{
  vector < OBJID > ids;
  vector < OBJID > outputCol;
  vector < MyDb::_ColIden >oc2ci;
  vector < int > oc2idx;
  //size_t cur_pos;
    list < vector < OBJID > >::iterator iter;
    list < vector < OBJID > >rows;
  void reset ()
  {
    //cur_pos = 0;
    outputCol.clear ();
    oc2idx.clear ();
    ids.clear ();
    rows.clear ();
    oc2ci.clear();
  }

  void conv ()
  {
    IdManager *im = IdManager::getInstance ();
    /*for (int i = 0; i < ids.size(); ++i) {
        cerr << "name:" << im->getNameById(ids[i]) << endl;
    }*/
    for (int i = 0; i < outputCol.size (); i++)
      {
	OBJID tid = im->getInfoById (outputCol[i]).parent;
	assert (tid != 0);
	MyDb *db = id2db[tid];
	assert (db != NULL);
	int idx = db->cid2index (outputCol[i]);
	oc2ci.push_back (MyDb::_ColIden (db, idx));
       // cerr << "tttid: " << im->getNameById(tid) << endl;
	for(int j=0;j<ids.size();j++){
	  if(ids[j] == tid ){
       //       cerr << "id:" << im->getNameById(ids[j]) << endl;;
       //       cerr << "tid:" << im->getNameById(tid) << endl;;
		oc2idx.push_back(j);
		break;
	  }
	}
       // cerr << "ids.size():"  << ids.size() << endl;
	  }

    if (oc2idx.size() != oc2ci.size()) {
        cerr << "size unequal: " << endl;
        cerr << oc2idx.size() << endl;
        cerr << oc2ci.size() << endl;
    }
    assert(oc2idx.size() == oc2ci.size());
	 assert(oc2ci.size() == outputCol.size());
    //assert (ps._col2tab.size () == ps._outputCol.size ());

  }
};

#endif
